﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class login : System.Web.UI.Page
{
    User user;
    userDAO dao;

    protected void Page_Load(object sender, EventArgs e)
    {
        user = new User();
        dao = new userDAO();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        checkLogin();
    }

    private void checkLogin()
    {
        user.Username = username.Text;
        user.Password = pass.Text;
        DataSet dsUser = new DataSet();
        dsUser = dao.checkLogin(user);
        if (dsUser.Tables[0].Rows.Count > 0)
       {
           Session.Add("USER", dsUser);
           Response.Redirect("home.aspx");
       }
        else
        {
            Response.Redirect("login.aspx");
        }

    }
}